function a(a, e, t) {
    return e in a ? Object.defineProperty(a, e, {
        value: t,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : a[e] = t, a;
}

var e = getApp(), t = require("../../utils/api.js");

Page({
    data: {
        cashInfo: "",
        cashType: "wx",
        showLoding: !0,
        value: 0,
        than: !1,
        less: !0,
        lessMoney: 1
    },
    onLoad: function(a) {
        var o = this;
        t.seeTeamData({
            openid: e.globalData.openid
        }).then(function(a) {
            console.log(a), 0 == a.errno && o.setData({
                cashInfo: a.data
            });
        }), t.TeamWallet({
            openid: e.globalData.openid
        }).then(function(a) {
            console.log(a), o.setData({
                cashTotalInfo: a.data
            });
        }), t.seeTeam({
            openid: e.globalData.openid
        }).then(function(a) {
            console.log(a), o.setData({
                lessMoney: a.data.get_cash_limit_money
            });
        });
    },
    navchange: function(a) {
        console.log(a);
        var e = this, t = a.currentTarget.dataset.type;
        e.setData({
            cashType: t,
            name: "",
            bankName: "",
            account: ""
        });
    },
    changeinfo: function(a) {
        console.log(a);
        var e = this, t = a.currentTarget.dataset.types, o = a.detail.value;
        "account" == t && e.setData({
            account: o
        }), "name" == t && e.setData({
            name: o
        }), "bankname" == t && e.setData({
            bankName: o
        });
    },
    allcash: function() {
        var a = this, e = a.data.cashInfo.cash;
        parseInt(e) < parseFloat(a.data.lessMoney) ? a.setData({
            cash: e,
            than: !1,
            less: !0,
            value: 0
        }) : a.setData({
            cash: e,
            than: !1,
            less: !1,
            value: e
        });
    },
    btn: function(e) {
        var o = this, n = o.data.value, s = o.data.cashType;
        if (console.log(n), "" == n) return !1;
        if ("wx" == s) {
            console.log(e);
            c = {
                openid: wx.getStorageSync("openid"),
                money: parseFloat(n).toFixed(2),
                form_id: e.detail.formId,
                type: 1
            };
        } else if ("zfb" == s) {
            if (console.log(e), "" == o.data.account || void 0 == o.data.account) return wx.showToast({
                title: "请填写支付宝账号",
                icon: "none",
                duration: 2e3
            }), !1;
            if ("" == o.data.name || void 0 == o.data.name) return wx.showToast({
                title: "请填写真实姓名",
                icon: "none",
                duration: 2e3
            }), !1;
            c = {
                openid: wx.getStorageSync("openid"),
                money: parseFloat(n).toFixed(2),
                form_id: e.detail.formId,
                account: o.data.account,
                name: o.data.name,
                type: 2
            };
        } else if ("wy" == s) {
            if (console.log(e), "" == o.data.account || void 0 == o.data.account) return wx.showToast({
                title: "请填写银行卡账号",
                icon: "none",
                duration: 2e3
            }), !1;
            if ("" == o.data.name || void 0 == o.data.name) return wx.showToast({
                title: "请填写真实姓名",
                icon: "none",
                duration: 2e3
            }), !1;
            if ("" == o.data.bankName || void 0 == o.data.bankName) return wx.showToast({
                title: "请填写银行卡开户行名称",
                icon: "none",
                duration: 2e3
            }), !1;
            var c = {
                openid: wx.getStorageSync("openid"),
                money: parseFloat(n).toFixed(2),
                form_id: e.detail.formId,
                account: o.data.account,
                name: o.data.name,
                bankName: o.data.bankName,
                type: 3
            };
        }
        console.log(c), t.applyGetCash(c).then(function(e) {
            console.log(e);
            var t = parseFloat(o.data.cashInfo.cash) - n;
            if (t < 0 && (t = 0), 1 == e.errno) {
                var s;
                o.setData((s = {}, a(s, "cashInfo.cash", t.toFixed(2)), a(s, "cash", ""), a(s, "less", !0), 
                a(s, "name", ""), a(s, "bankName", ""), a(s, "account", ""), s));
            } else o.setData({
                cash: "",
                less: !0
            });
            wx.showToast({
                title: e.message,
                icon: "none",
                duration: 2e3
            });
        });
    },
    money: function(a) {
        var e = this, t = a.detail.value;
        console.log(parseFloat(t)), parseFloat(t) > parseFloat(e.data.cashInfo.cash) ? e.setData({
            than: !0,
            less: !1
        }) : isNaN(parseFloat(t)) ? e.setData({
            less: !0,
            than: !1,
            cash: ""
        }) : "" == t ? e.setData({
            less: !0,
            than: !1,
            cash: ""
        }) : t < parseFloat(e.data.lessMoney) ? e.setData({
            less: !0,
            than: !1
        }) : (e.setData({
            than: !1,
            value: t,
            cash: t,
            less: !1
        }), console.log(e.data.value));
    }
});